﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                Console.WriteLine("-----------欢迎来到野球拳大舞台-------------");
                Console.WriteLine("*************************************************");
                Console.WriteLine("*******************开始击剑**********************");
                Console.WriteLine("*************************************************");

                Console.WriteLine("出拳规则：1.剪刀，2.石头，3.布");
                Console.WriteLine("请选择您的对手：1:：刘备，2：孙权，3：曹操");
                int y = Convert.ToInt32(Console.ReadLine());
                Npc n1 = new Npc();
                switch (y)
                {
                    case 1:
                        n1.Npcname = "蛇喰梦子";
                        break;
                    case 2:
                        n1.Npcname = "皇伊月";
                        break;
                    case 3:
                        n1.Npcname = "生志摩妄";
                        break;
                    default:
                        break;
                }
                Console.WriteLine("您的对手为" + n1.Npcname);
                Console.WriteLine();

                Console.WriteLine("请输入您的角色名");
                string name = Console.ReadLine();
                Player p1 = new Player();
                p1.Name = name;
                Console.WriteLine("您的角色名为" + p1.Name);
                Console.WriteLine();
                Console.WriteLine("是否开始游戏（y/n）");
                string x = Console.ReadLine();
                if (x == "y")
                {
                    Console.WriteLine("{0}Vs{1},Deul!", p1.Name, n1.Npcname);
                }
                else
                {
                    Console.WriteLine("怂了，就这？");
                    Console.WriteLine("不会真有人选n吧不会吧不会吧？");
                }
                int Cishu = 0;
                int NY = 0;
                int PY = 0;
                Boolean faalg = true;
                while (true)
                {
                    Cai(p1, n1);
                    Cishu = Cishu + 1;
                    Console.WriteLine("还继续吗？（y/n）");
                    string Jixu = Console.ReadLine();

                    if (Jixu == "n")
                    {
                        Console.WriteLine("行吧，输了就想跑呗。");
                        faalg = false;
                        break;
                    }
                }
                
                Console.WriteLine("=============================");
                Console.WriteLine(p1.Name + "VS" + n1.Npcname);
                Console.WriteLine("对战次数" + Cishu);
                Console.WriteLine("名字-----------得分");
                Console.WriteLine(n1.Npcname + "-----------" + n1.Ying);
                Console.WriteLine(p1.Name + "-----------" + p1.Ying);
                Console.WriteLine("再来一把？(y/n)");
                string Zai = Console.ReadLine();
                if (Zai=="n")
                {
                    Console.WriteLine("滚吧滚吧，晦气");
                    break;
                }
            }

        }
        public static void Cai(Player p1, Npc n1)
        {
            Console.WriteLine("请出拳：1.剪刀，2.石头，3.布（请输入相应数字）");
            int pchu = Convert.ToInt32(Console.ReadLine());
            Random rd = new Random();
            int nchu = rd.Next(1, 3);
            
                
                    p1.Pchu = pchu;
                    n1.Nchu = nchu;
                    p1.Say();
                    n1.Say();


                    Pan(p1, n1);
                               
        }
        public static void Pan(Player p1, Npc n1)
        {
            Boolean falg;
            if (p1.Pchu==n1.Nchu)
            {
                Console.WriteLine("平局，真可惜啊");
            }
            else 
            {
                if (p1.Pchu>n1.Nchu)
                {
                    if (p1.Pchu==3&&n1.Nchu==1)
                    {
                        falg = false;//npc赢
                        ny(n1);
                        Console.WriteLine("你输了，菜不菜啊。");
                    }
                    else
                    {
                        falg = true;//玩家赢
                        py(p1);
                        Console.WriteLine("让你一把而已。");
                    }
                }
                else if(n1.Nchu>p1.Pchu)
                {
                    if (n1.Nchu==3&&p1.Pchu==1)
                    {
                        falg = true;//玩家赢
                        py(p1);
                        Console.WriteLine("让你一把而已。");
                    }
                    else
                    {
                        falg = false;//npc赢
                        ny(n1);
                        Console.WriteLine("你输了，菜不菜啊。");
                    }
                }

                 
            }
        }
        public static Player py(Player p1)
        {
           p1.Ying =p1.Ying + 1;
            return p1;
        }
        public static Npc ny(Npc n1)
        {
             n1.Ying=n1.Ying + 1;
            return n1;
        }

    }
}
